{extend name="../../base/view/layout" /}
{block name="my_body"}
<div class="widgetbox box-inverse">
    <div class="widgetcontent wc1">

        <form id="form1" class="stdform" >
            <div class="tabbable">
                <ul class="nav nav-tabs buttons-icons">
                    <li class="active"><a data-toggle="tab" href="#shop_info"><?php echo $_page_title;?></a></li>
                </ul>
                <div class="tab-content">
                    <div id="shop_info" class="tab-pane active">

            <div class="par control-group">
                <label class="control-label" >类型</label>
                <div class="controls">
                    <select name="type_id" id="type_id">
                        <?php foreach($typeData as $v):?>
                        <option value="<?php echo $v['id'];?>" <?php if($v['id'] == $data['type_id']) echo 'selected';?> ><?php echo $v['name'];?></option>
                        <?php endforeach;?>
                    </select>
                </div>
            </div>
            <input type="hidden" name="id" value="<?php echo $data['id'];?>" />
            <div class="par control-group">
                <label class="control-label" for="attr_name">属性名称</label>
                <div class="controls"><input type="text" name="attr_name" id="attr_name" class="input-xlarge" value="<?php echo $data['attr_name'];?>" /></div>
            </div>

            <div class="par control-group">
                <label class="control-label" >属性类型</label>
                <div class="controls">
                    <input type="radio" name="attr_type" value="可选" class="input-xlarge" <?php if($data['attr_type'] == '可选') echo "checked" ;?> />可选
                    <input type="radio" name="attr_type" value="唯一" class="input-xlarge" <?php if($data['attr_type'] == '唯一') echo "checked" ;?> />唯一
                </div>
            </div>

            <div class="par control-group">
                <label class="control-label" for="attr_option_values">属性可选值</label>
                <div class="controls"><textarea name="attr_option_values" id="attr_option_values" rows="5" style="width:300px;"><?php echo $data['attr_option_values'];?> </textarea></div>
            </div>
                    </div>
                </div>
            </div>


            <p class="stdformbutton">
                <a class="btn btn-primary">提交</a>
            </p>
        </form>
    </div><!--widgetcontent-->
</div><!--widget-->
{/block}

{block name="my_js"}
<script>
    var url = "<?php echo url('edit');?>";
    var jumpUrl = "<?php echo url('lst');?>";
    jQuery('.stdformbutton .btn').click(function(){
    var formData = jQuery("#form1").serialize();//序列化表格内容为字符串
            jQuery.ajax({
                type: 'POST',
                url: url,
                data: formData ,
                dataType: 'JSON',
                success: function(res){
                    if(res.code == 0)
                    {
                        var checkValue=jQuery("#type_id").val();  //获取Select选择的Value
                        window.location.href=jumpUrl+'?type_id='+checkValue;
                    }
                    else
                    {
                        var html = '<div class="widgetbox box-danger"><h4 class="widgettitle">错误提示 <a class="close">×</a> <a class="minimize">–</a></h4><div class="widgetcontent">'+res.msg+'</div></div>';
                        var h = jQuery(html);
                        jQuery(".widgetcontent").prepend(h);
                        window.setTimeout(function(){
                            h.remove();
                        },1000);
                    }
                }
            })
        }
    );
</script>
{/block}